package k2_oop.p9_collection.demo13;

import java.util.LinkedList;
import java.util.Queue;

public class ChooseMonkeyKing {
    public static void main(String[] args) {

        Queue<String> monkeyQueue = new LinkedList<>();

        for (int i = 1; i <= 15; i++) {
            monkeyQueue.add("猴子"+i+"号");
        }

        System.out.println(monkeyQueue);

        //初始化一个计数器
        int counter = 0;

        while(monkeyQueue.size()>1){
            if(++counter % 7==0){
                System.out.println(monkeyQueue.remove()+"被淘汰");
            }else{
                monkeyQueue.add(monkeyQueue.remove());
            }
            System.out.println(monkeyQueue);
        }
    }
}
